import Mock from 'mockjs'

import qs from 'querystring'
import id from "element-ui/src/locale/lang/id";
import el from "element-ui/src/locale/lang/el";


Mock.mock("/getRecommend", "post", {
    data: [{
        getrecommendtext: "酷极 后现代简约北欧式轻奢led落地灯客厅卧室书房间床头阅读沙发茶几带置物架网红落坐地站立式灯饰 A款 黑体-翡翠玻璃 12W三色调光",
        id: 1,
        price: "1064.00",
        title: "酷极",
        url: "https://img13.360buyimg.com/n1/jfs/t1/199329/7/18798/124134/61a45436Ea3830b38/8cc3bffeff038e20.jpg"
    }, {
        getrecommendtext: "安迪慕品高端珠帘水晶装饰水晶帘子玄关隔断帘欧式客厅餐厅卧室屏风挂帘免打孔 金黄色+透明色 21条长0.5米短0.3米雨林",
        id: 2,
        price: "189.00",
        title: "安迪",
        url: "https://img14.360buyimg.com/n1/jfs/t1/207534/18/8737/109562/618a2484E5deaef95/eaff36351e97f82e.jpg"
    }, {
        getrecommendtext: "茜衡茶具官方店创意茶宠摆件禅意小和尚紫砂精品茶室茶桌装饰茶具配件摆设 静修禅僧(坐)送佛珠",
        id: 3,
        price: "169.00",
        title: "茜衡茶具",
        url: "https://img11.360buyimg.com/n1/jfs/t1/198299/19/6688/120651/6133596bEbf0f24d9/d4962272ae7682ef.jpg"
    }, {
        getrecommendtext: "JOY STUDIO新款京东吉祥物京东狗毛绒公仔玩具玩偶摆件中号京东JOY版厂家直发 可定制带LOGO水洗标",
        id: 4,
        price: "18.00",
        title: "京东",
        url: "https://img14.360buyimg.com/n1/jfs/t1/6119/13/6702/46845/5be1059fE0a4e4c22/cc8bc9f3682aad90.jpg"
    }, {
        getrecommendtext: "多功能简约抽屉式桌面收纳盒梳妆台护肤品学生文具杂物整理 3010-3三层灰色",
        id: 5,
        price: "84.50",
        title: "抽屉",
        url: "https://img11.360buyimg.com/n1/jfs/t1/90576/17/19854/36784/615d661dE50a05e9f/b1d93978a7d3cb85.jpg"
    }, {
        getrecommendtext: "利得物业垃圾袋 特大号加厚黑色实惠装平装100*120cm*50只",
        id: 6,
        price: "43.9",
        title: "利德",
        url: "https://img11.360buyimg.com/n1/jfs/t1/75025/27/16310/141112/60ee73faE23b115f2/60aeb978b852d0c1.jpg"
    }]
})

Mock.mock(RegExp("/recomendInfo" + ".*"), "get", req=>{
    // data: [{
    //     contenttext: "酷极 后现代简约北欧式轻奢led落地灯客厅卧室书房间床头阅读沙发茶几带置物架网红落坐地站立式灯饰 A款 黑体-翡翠玻璃 12W三色调光",
    //     id: 1,
    //     price: "1064.00",
    //     titletext: "酷极",
    //     url: "https://img13.360buyimg.com/n1/jfs/t1/199329/7/18798/124134/61a45436Ea3830b38/8cc3bffeff038e20.jpg"
    // }]

    const { url } = req
    const getparams = url.split("recomendInfo/")[1]
  console.log(getparams==='1')
    if (getparams === '1'){
      return {
        status:200,
        data:{
          contenttext: "安迪慕品高端珠帘水晶装饰水晶帘子玄关隔断帘欧式客厅餐厅卧室屏风挂帘免打孔 金黄色+透明色 21条长0.5米短0.3米雨林",
          id: 2,
          price: "189.00",
          titletext: "安迪",
          url: "https://img14.360buyimg.com/n1/jfs/t1/207534/18/8737/109562/618a2484E5deaef95/eaff36351e97f82e.jpg"
        }
      }
    }else if (getparams === '2'){
      return {
        status:200,
        data:{
          contenttext: "安迪慕品高端珠帘水晶装饰水晶帘子玄关隔断帘欧式客厅餐厅卧室屏风挂帘免打孔 金黄色+透明色 21条长0.5米短0.3米雨林",
          id: 1,
          price: "1064.00",
          titletext: "酷极",
          url: "https://img13.360buyimg.com/n1/jfs/t1/199329/7/18798/124134/61a45436Ea3830b38/8cc3bffeff038e20.jpg"
        }
      }
    }
    else if (getparams === '3'){
      return {
        status:200,
        data:{
          contenttext: "茜衡茶具官方店创意茶宠摆件禅意小和尚紫砂精品茶室茶桌装饰茶具配件摆设 静修禅僧(坐)送佛珠",
          id: 3,
          price: "169.00",
          titletext: "茜衡茶具",
          url: "https://img11.360buyimg.com/n1/jfs/t1/198299/19/6688/120651/6133596bEbf0f24d9/d4962272ae7682ef.jpg"
        }
      }
    }else if (getparams === '4'){
      return {
        status:200,
        data:{
          contenttext: "JOY STUDIO新款京东吉祥物京东狗毛绒公仔玩具玩偶摆件中号京东JOY版厂家直发 可定制带LOGO水洗标",
          id: 4,
          price: "18.00",
          titletext: "京东",
          url: "https://img14.360buyimg.com/n1/jfs/t1/6119/13/6702/46845/5be1059fE0a4e4c22/cc8bc9f3682aad90.jpg"
        }
      }
    }else if (getparams === '5'){
      return {
        status:200,
        data:{
          contenttext: "多功能简约抽屉式桌面收纳盒梳妆台护肤品学生文具杂物整理 3010-3三层灰色",
          id: 5,
          price: "84.50",
          titletext: "抽屉",
          url: "https://img11.360buyimg.com/n1/jfs/t1/90576/17/19854/36784/615d661dE50a05e9f/b1d93978a7d3cb85.jpg"
        }
      }
    }else if (getparams === '6'){
      return {
        status:200,
        data:{
          contenttext: "利得物业垃圾袋 特大号加厚黑色实惠装平装100*120cm*50只",
          id: 6,
          price: "43.9",
          titletext: "利德",
          url: "https://img11.360buyimg.com/n1/jfs/t1/75025/27/16310/141112/60ee73faE23b115f2/60aeb978b852d0c1.jpg"
        }
      }
    }
})

Mock.mock("/login","post",req =>{
  const {username,password} = JSON.parse(req.body)

  console.log(username)
  if (username === "admin" && password === "123456"){
    return{
      status:200,
      user:{
        username:"admin",
        password:"123456"
      },
      message:"success"
    }
  }else {
    return {
      status: 404,
      message: "账号或者密码错误"
    }
  }
})

Mock.mock("/getAddressList","post",{
  data:[{
    id: '1',
    name: '张三',
    tel: '13000000000',
    address: '浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室',
    isDefault: true,
    },
    {
      id: '2',
      name: '李四',
      tel: '1310000000',
      address: '浙江省杭州市拱墅区莫干山路 50 号',
    },
    {
      id: '3',
      name: '王五',
      tel: '1320000000',
      address: '浙江省杭州市滨江区江南大道 15 号',
    },]
})
